package org.zju.demo.service.impl;

import org.zju.demo.model.OrderProduct;
import org.zju.demo.service.intf.OrderProductIntf;
import org.zju.demo.utils.HibernateUtil;

import java.util.List;

/**
 * Created by admin on 2015/8/27.
 */
public class OrderProductImpl implements OrderProductIntf {
    public int addItem(OrderProduct obj) {
        return HibernateUtil.saveIfNotExists(obj);
    }

    public List<OrderProduct> findByOrderId(int orderId) {
        String hql = "from OrderProduct where orderId=?";
        String[] parameters = {Integer.toString(orderId)};
        List<OrderProduct> list = HibernateUtil.executeQuery(hql, parameters);
        return list;
    }

}
